package com.terrier.ui.controls.sliderClasses
{
    import com.terrier.ui.controls.supportClasses.WxTrackBase;
    import com.terrier.ui.events.WxButtonEvent;
    import com.terrier.ui.managers.WxToolTipManager;
    
    import flash.geom.Point;

    /**
     * 滑块组件基类. 它是水平滑块组件和垂直滑块组件的基类
     * @author Jarvis.weng
     */
    public class WxSliderBase extends WxTrackBase
    {
        /**
         * 构造函数
         */
        public function WxSliderBase()
        {
            super();
        }

        /**
         * @private
         */
        override protected function initialize():void
        {
            super.initialize();

            track.addEventListener(WxButtonEvent.BUTTON_PRESS, pressTrackHandler);
        }

        private function pressTrackHandler(e:WxButtonEvent):void
        {
            var pt:Point = new Point(track.mouseX, track.mouseY);
            value = pointToValue(pt);
        }

        /**
         * @private
         */
        protected override function startDragThumb(pt:Point):void
        {
            toolTipShowDelay = 0;
            toolTipHideDelay = int.MAX_VALUE;
            toolTip = value;
        }

        /**
         * @private
         */
        protected override function stopDragThumb(pt:Point):void
        {
            toolTip = null;
        }

        /**
         * @private
         */
        protected function updateToolTip():void
        {
            toolTip = value;
            WxToolTipManager.instance.updateToolTip(this);
        }
    }
}
